#namespace("dbConfig")

 #### 创建日志表
 #sql("createLogTable")
     #---
     drop table #(tableName);
     create table #(tableName) (
       id int NOT NULL IDENTITY(1,1) ,
       updateTime datetime not null default(getdate()),
       code nvarchar(20) not null default(''),
       remark nvarchar(80) not null default(''),
       unit nvarchar(20) not null default(''),
       address nvarchar(50) not null default(''),
       paramValue nvarchar(20) not null default('')
       PRIMARY KEY (id)
     );
     --#
     exec sp_rename '#(tableName).rackNo','hangerNo'
     go
     EXEC sp_addextendedproperty
     'MS_Description', '更新时间',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'updateTime' ;

     EXEC sp_addextendedproperty
     'MS_Description', '编码',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'code';

     EXEC sp_addextendedproperty
     'MS_Description', '备注',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'remark' ;

     EXEC sp_addextendedproperty
     'MS_Description', '工程单位',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'unit';

     EXEC sp_addextendedproperty
     'MS_Description', '变量地址',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'address' ;

     EXEC sp_addextendedproperty
     'MS_Description', '参数值',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'paramValue';

     EXEC sp_addextendedproperty
     'MS_Description', '挂具编号',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'hangerNo' ;

     EXEC sp_addextendedproperty
     'MS_Description', '电泳框编号',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'frameNo';

     EXEC sp_addextendedproperty
     'MS_Description', '条码',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)',
     'COLUMN', 'barcode' ;

     EXEC sp_addextendedproperty
     'MS_Description', '#(tableRemark)',
     'SCHEMA', 'dbo',
     'TABLE', '#(tableName)';

 #end


#### 创建日志表
 #sql("createLogTableInPg")
     drop table #(tableName);
     CREATE TABLE #(tableName) (
       update_time TIMESTAMPTZ  NOT NULL ,
       code varchar(50) NOT NULL DEFAULT (''),
       remark  varchar(100) NOT NULL DEFAULT (''),
       unit varchar(50)  NOT NULL DEFAULT (''),
       address varchar(30) NOT NULL DEFAULT (''),
       param_value double precision NOT NULL DEFAULT (0.0),
       primary key(update_time)
     );
     comment on table #(tableName) is '#(tableRemark)';
     comment on column #(tableName).update_time is '更新时间';
     comment on column #(tableName).code is '编码';
     comment on column #(tableName).remark is '备注';
     comment on column #(tableName).unit is '工程单位';
     comment on column #(tableName).address is '变量地址';
     comment on column #(tableName).param_value is '参数值';
     select create_hypertable('#(tableName)','update_time');
 #end


#sql("createHangerFrameMiddle")
insert into t_hanger_frame_middle(hanger_no,frame_no)
values
#for(x : list )
('#(x.hangerNo)','#(x.frameNo)'),
#end

#end

#end